/**
 * 版权所有:(C)2001-2012 北京中油瑞飞信息技术有限责任公司
 * Author : 李科风
 * Creation time : 2014年8月13日 下午2:22:32
 */
package com.bigknow.appstore.common.rpc;

import java.lang.reflect.Method;

public class RPCUtil {

	private static RPCClassLoader classLoader = new RPCClassLoader();

	public static void parseInterfaceClass(Class<?> interfaceClass) {
		if (!interfaceClass.isInterface()) {
			throw new RuntimeException("参数必须为接口");
		}
	}

	public static RPCClassLoader getClassLoader() {
		return classLoader;
	}

	public static String getMethodRequestName(Method method, String className) {
		if (method.getParameterTypes().length == 0) {
			return RPCRequest.class.getName();
		} else {
			return className + "_" + method.getName() + "_Request";
		}
	}

	public static String getMethodResponseName(Method method, String className) {
		if (method.getReturnType() == void.class) {
			return RPCResponse.class.getName();
		} else {
			return className + "_" + method.getName() + "_Response";
		}
	}

	public static String getImplClassName(Class<?> interfaceClass) {
		return interfaceClass.getName() + "$Impl";
	}

	public static String getProxyClassName(Class<?> interfaceClass, Method method) {
		return interfaceClass.getName() + "$Proxy_" + method.getName();
	}
}
